//
// Description: 367. 有效的完全平方数
// Created by Loading on 2021/11/4.
//

#include <bits/stdc++.h>

using namespace std;

bool isPerfectSquare(int num) {
    int l = 1, r = num / 2 + 1;
    while (l <= r) {
        /* 乘法运算 int 会溢出，使用 long long */
        long long mid = l + (r - l) / 2;
        if (mid * mid == num) {
            return true;
        }
        if (mid * mid < num) {
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }

    return false;
}

int main() {
    int num = 76;
    bool res = isPerfectSquare(num);
    cout << res << endl;

    return 0;
}